package com.wteam.controller;

import com.wteam.PoJo.DTO.coupon;
import com.wteam.PoJo.DTO.memberdto;
import com.wteam.PoJo.VO.*;
import com.wteam.service.MemberService;
import com.wteam.untils.Result;
import com.wteam.untils.aliyun.AliOSS;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/member")

@Api(tags = "用户接口")
public class membercontroller {

    @Autowired
    private HttpServletRequest httpServletRequest;

    @Autowired
    private AliOSS aliOSS;
    @Autowired
    private MemberService memberService;

    /**
     *
     * @param file
     * @return
     * @throws IOException
     */
    @ApiOperation(value = "上传用户头像")
    @PostMapping("/upload")
    public Result<String> upload(@RequestParam MultipartFile file) throws IOException {
        String url = memberService.upload(file);
        return Result.success(url);
    }


    /**
     *
     * @param walletPassword
     * @return
     */
    @ApiOperation(value = "设置钱包密码")
    @PostMapping("/savewallet")
    public Result savewallet(@RequestBody @Valid walletPassword walletPassword) {


        return memberService.savewallet(walletPassword);
    }

    /**
     *
     * @param money
     * @return
     */
    @ApiOperation(value = "充值")
    @PutMapping("/savemoney")
    public Result savemoney(@RequestBody money money) {
        return memberService.savemoney(money);
    }


    /**
     *
     * @return
     */
    @ApiOperation(value = "每日签到换积分")
    @GetMapping("/Signpoint")
    public Result signpoint() {
        return memberService.signpoint();
    }

    /**
     *
     * @return
     */
    @ApiOperation(value = "查看本月的签到情况")
    @GetMapping("/selectsign")
    public Result<List<sign>> SelectSign() {
        return memberService.selectsign();
    }

    /**
     *
     * @param point
     * @return
     */
    @ApiOperation(value = "分享换积分")
    @GetMapping("/share/{point}")
    public Result SharePoint(@ApiParam(value = "福荣说这个积分他来") @PathVariable Integer point) {
        return memberService.SharePoint(point);
    }


    /**
     *
     * @return
     */
    @ApiOperation(value = "查看我的优惠卷")
    @GetMapping("/mycoupon")
    public Result<List<coupon>> UserGetCopon() {
        return memberService.selectMyCopon();
    }

    /**
     *
     * @return
     */
    @ApiOperation(value = "查看我的积分")
    @GetMapping("/mypoint")
    public Result<memberpoint> Mypoint() {
        return memberService.selectMypoint();
    }

    /**
     *
     * @return
     */
    @ApiOperation(value = "个人中心（查具体信息）")
    @GetMapping("/mybody")
    public Result<memberdto> Mybody() {
        return memberService.selectMybody();
    }

    /**
     *
     * @param fixmybody
     * @return
     */
    @ApiOperation(value = "修改我的用户信息")
    @PutMapping("/fixmybody")
    public Result<fixmybody> fixMybody(@RequestBody @Validated fixmybody fixmybody) {
        return memberService.fixmybody(fixmybody);
    }


}
